<template>
  <div class="container">
    <el-dialog
      title="题目审核"
      :visible.sync="dialogFormVisible"
      width="20%"
      @close="cancel"
    >
      <el-radio v-model="radio" label="1">通过</el-radio>
      <el-radio v-model="radio" label="2">拒绝</el-radio>
      <el-form ref="form" :model="form" :rules="rules">
        <el-form-item class="text" prop="audit">
          <el-input
            type="textarea"
            v-model="form.audit"
            placeholder="请输入审核意见"
          ></el-input>
        </el-form-item>
        <div class="btn">
          <el-button @click="cancel">取消</el-button>
          <el-button type="primary" @click="confirm(row)" class="confirm"
            >确认</el-button
          >
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  props: ['row'],
  data () {
    return {
      radio: '1',
      dialogFormVisible: false,
      form: {
        audit: ''
      },
      rules: {
        audit: [{ required: true, message: '不能为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    // 弹层显示
    dialogFormV () {
      this.dialogFormVisible = true
    },
    // 弹层隐藏
    dialogFormH () {
      this.dialogFormVisible = false
    },
    // 提交表单
    async confirm () {
      // form表单验证
      await this.$refs.form.validate()
      const obj = {
        id: this.row.id,
        chkRemarks: this.form.audit,
        chkState: +this.radio
      }
      await choiceCheck(obj)
      this.cancel()
      this.$parent.initData()
    },
    // 取消
    cancel () {
      this.$refs.form.resetFields()
      this.dialogFormH()
    }
  }
}
</script>

<style scoped lang="less">
.text {
  margin: 30px 0;
}
.btn {
  .el-button {
    margin-left: 180px;
  }
  .confirm {
    margin-left: 20px;
  }
}
</style>
